package tool.disuse;
/** 能否改成单例模式  或静态方法
 *OA user psw  crack
 * commons-codec-1.6.jar
 */
import org.apache.commons.codec.binary.Base64;


public class Base64Code {
	
	public Base64Code(){
		Base64 base64=new Base64();
	}
	
	public String encode(String str){
		byte[] s1=str.getBytes();
		byte[] s2=Base64.encodeBase64(s1);
		String s=new String(s2);
		return s;
		
	}
	
	public String decode(String str){
		byte[] s1=str.getBytes();
		byte[] s2=Base64.decodeBase64(s1);
		String s=new String(s2);
		return s;
	}
	
	
	public String myencode(String str){
		Base64Code bc=new Base64Code();
		return "MD5"+bc.encode(str);
	}
	
	public String reverse(String str){
		StringBuffer sb=new StringBuffer(str);
		return sb.reverse().toString();
	}
	
	
	public String mydecode(String str){
		
		char[] s=str.toCharArray();
		StringBuffer sb=new StringBuffer();;
		int i=0;
		for(char c:s){
			++i;
			if(i>3){
				sb.append(c);
			}

		}
		Base64Code bc=new Base64Code();
		return bc.decode(sb.toString());
		
	}
	
	public static void main(String[] args){
		
		Base64Code b=new Base64Code();
//		System.out.println(b.encode(""));
		System.out.println(b.decode("emhyNzUwNzQwOTkw"));
		System.out.println(b.myencode("123456"));
		System.out.println(b.mydecode("MD5OTY5OTE1NzU="));
		
		System.out.println(b.decode("5Lul5YmN56ef55So5py65qKw77yM546w5qyy6LStMjEw5oiWMjUw"));


		
	
	}

}
